<?php

/**
 * This is the model class for table "{{r_entidad}}".
 *
 * The followings are the available columns in table '{{r_entidad}}':
 * @property integer $grid_entidad_id
 * @property string $grid_entidad_tipo
 * @property string $grid_grupo
 * @property string $grid_genero
 * @property integer $grid_pais_id
 * @property integer $user_id
 * @property string $ip_registro
 * @property string $fecha_registro
 * @property integer $grid_deporte_actividad_id
 */
class REntidad extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return REntidad the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{r_entidad}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('grid_entidad_tipo, grid_genero, grid_pais_id, ip_registro, fecha_registro, grid_deporte_actividad_id', 'required'),
			array('grid_pais_id, user_id, grid_deporte_actividad_id', 'numerical', 'integerOnly'=>true),
			array('grid_entidad_tipo', 'length', 'max'=>15),
			array('grid_grupo', 'length', 'max'=>200),
			array('grid_genero', 'length', 'max'=>40),
			array('ip_registro', 'length', 'max'=>45),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('grid_entidad_id, grid_entidad_tipo, grid_grupo, grid_genero, grid_pais_id, user_id, ip_registro, fecha_registro, grid_deporte_actividad_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'gridDeporteActividad' => array(self::BELONGS_TO, 'DeporteActividad', 'grid_deporte_actividad_id'),
			'gridPais' => array(self::BELONGS_TO, 'Pais', 'grid_pais_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'grid_entidad_id' => 'Grid Entidad',
			'grid_entidad_tipo' => 'TIPO :',
			'grid_grupo' => 'DESCRIPCIÓN :',
			'grid_genero' => 'GÉNERO :',
			'grid_pais_id' => 'PAÍS :',
			'user_id' => 'User',
			'ip_registro' => 'Ip Registro',
			'fecha_registro' => 'Fecha Registro',
			'grid_deporte_actividad_id' => 'DEPORTE :',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('grid_entidad_id',$this->grid_entidad_id);
		$criteria->compare('grid_entidad_tipo',$this->grid_entidad_tipo,true);
		$criteria->compare('grid_grupo',$this->grid_grupo,true);
		$criteria->compare('grid_genero',$this->grid_genero,true);
		$criteria->compare('grid_pais_id',$this->grid_pais_id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('ip_registro',$this->ip_registro,true);
		$criteria->compare('fecha_registro',$this->fecha_registro,true);
		$criteria->compare('grid_deporte_actividad_id',$this->grid_deporte_actividad_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}